<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/admin.css">
    <title>许久没道过早安的后台</title>
    <style>
        #input{
            width: 500px;
            margin-top:20px;
        }
        #label{
            width:800px;
        }
        #submit{
            /*float:right;*/
            margin-left:50px;
        }
    </style>
</head>
<body>
<div class="body">
    <div class="layui-fluid">
        {include file='public/sider' /}
        <div id="main">
            {include file='public/header' /}

            <div class="layui-fluid" id="body">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div class="layui-form">
                            <div id="input">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">
                                        链接名称
                                    </label>
                                    <div class="layui-input-block">
                                        <input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">
                                        链接地址
                                    </label>
                                    <div class="layui-input-block">
                                        <input type="text" name="link" placeholder="请输入" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    是否展示
                                </label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="show" value="1" title="展示">
                                </div>
                            </div>
                            <div id="submit">
                                <div class="layui-form-item">
                                    <button class="layui-btn" lay-submit lay-filter="form">提交</button>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="/static/layui/layui.js"></script>
<script>
    var height = window.screen.availHeight;
    document.getElementById('body').style.height = parseInt(height) - 190 + "px";
    document.getElementById('sider').style.height = parseInt(height) - 165 + "px";
    layui.use(['jquery','form','layer','layedit'],function(){
        var $ = layui.jquery;
        var form = layui.form;
        var layedit = layui.layedit;
        var layer = layui.layer;
        // 监听表单提交
        form.on('submit(form)',function(data){
            $.ajax({
                async: true,
                type: "POST",
                url: "{:url('link/link_add')}",
                data: data.field,
                success:function(data){
                    if(data.status == 200){
                        layer.msg(data.msg);
                        setTimeout(function(){
                            window.location.href="{:url('link/lst')}";
                        }, 2000);
                    }else{
                        layer.msg(data.msg);
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>